#include "threadPool.h"
#include "command.h"
int myRecvComd(char* comd, char* arg){
    //接受命令，参数
    
    return 0;
}                               
int myExecute(char* comd, char* arg);
int myCd(char* arg){
    char fname[25];
    int len;
    //   yfg/home/cpp_50/linux25/
    char* p = strtok(arg,"/");
    while(p != NULL){
        printf("%s-\n",p);
        p = strtok(NULL,"/");
        len = strlen(p);
        for(int i = 0; i < len; i++){
            fname[i] = *p;
            p++;
        }
        fname[len] = '\0';
        if()
    }
    return 0;
}
int myLs(char* arg);            
int myPuts();                   
int myGets();                   
int myRemove(char* arg);        
int myPwd();


//入栈
int Push(stack* curWorkDir,char* fname){
    node_t* pnew = (node_t*)malloc(sizeof(node_t));
    int len = strlen(fname);
    for(int i = 0; i < len; i++){
        pnew->fname[i] = *fname;
        fname++;
    }
    pnew->fname[len] = '\0';
    pnew->next = NULL;

    if(curWorkDir->top == NULL){
        curWorkDir->top  = pnew;
    }else{
        pnew->next = curWorkDir->top;
        curWorkDir->top = pnew;
    }
    printf("%s\n",curWorkDir->top->fname);
    curWorkDir->stackSize++;
    return 0;
}
//出栈
int Pop(stack* curWorkDir, char* fname){
    if(isEmpty(curWorkDir)){
        printf("stack is empty\n");
        return -1;
    }
    int len = strlen(curWorkDir->top->fname);
    for(int i = 0; i < len; i++){
        *fname = curWorkDir->top->fname[i];
        fname++;
    }
    *fname = '\0';

    node_t* pre = curWorkDir->top;
    curWorkDir->top = curWorkDir->top->next;
    free(pre);
    curWorkDir->stackSize--;
    return 0;
}

//查看栈顶
int Peek(stack* curWorkDir, char* fname){
    if(isEmpty(curWorkDir)){
        printf("stack is empty\n");
        return -1;
    }
    int len = strlen(curWorkDir->top->fname);
    for(int i = 0; i < len; i++){
        *fname = curWorkDir->top->fname[i];
        fname++;
    }
    *fname = '\0';
    return 0;
}
//判空
int isEmpty(stack* curWorkDir){
    return curWorkDir->stackSize == 0;
}
